package com.wk.pms.feign;

import com.wk.common.bean.Resp;
import com.wk.pms.entity.Category;
import com.wk.pms.vo.CategoryVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;


@FeignClient("pms-service")
@RequestMapping("category")
public interface CategoryFeign {

    /**
     * 根据一级分类ID查询对应的二三级分类信息
     */
    @GetMapping("{pid}")
    Resp<List<CategoryVO>> queryByPid(@PathVariable(value = "pid") Long pid);

    /**
     * 根据父类ID或三级分类中的级别查询分类信息
     * @param level
     * @param pid
     * @return
     */
    @GetMapping
    Resp<List<Category>> queryCategoriesByPidOrLevel(@RequestParam(value = "level", defaultValue = "0") Integer level,
                                                     @RequestParam(value = "parentCid", required = false) Long pid);

    /**
     * 根据分类ID查询分类
     * @param catId
     * @return
     */
    @GetMapping("/info/{catId}")
    Resp<Category> info(@PathVariable(value = "catId") Long catId);

}
